package com.myapp.dao.impl;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.Query;

import com.myapp.dao.PagoSocioDao;
import com.myapp.entity.PagoSocio;
import com.myapp.dao.impl.GeneralDaoImpl;

@Stateless
public class PagoSocioDaoImpl extends GeneralDaoImpl<PagoSocio, Long> implements
		PagoSocioDao {

	
	@SuppressWarnings("unchecked")
	public List<PagoSocio> consultarTotalPagoSocio(Long idSocio) {
		Query query = em.createNamedQuery("consultarTotalPagoSocio");
		query.setParameter("idSocioPagante",idSocio);
		List<PagoSocio> listPagos = (List<PagoSocio>)query.getResultList();
		if(listPagos!=null && listPagos.size()>0){
			return listPagos;
		}
		return null;
	}
	public Long consultarNumeroPagoSocio(Long idSocio) {
		Query query = em.createNamedQuery("consultarNumeroPagoSocio");
		query.setParameter("idSocioPagante",idSocio);
		Long numeroPagos = (Long)query.getSingleResult();
		if(numeroPagos!=null && numeroPagos>0){
			return numeroPagos;
		}
		return 0L;
	}
	

}
